'abuschedulecomponent.monkey by Belimoth
Strict
Import abucomponent
Import abu.abuschedule
Import reflection

'TODO
'	Tween methods don't work from here, have been overloaded in Entity class

Class ScheduleComponent Extends EntityComponent<ISchedule> Implements ISchedule

Public
	Method AddTween:Void(name:String, value:Float, duration:Int, flags:Int = TWEEN_DEFAULT)
		Local tweenNew := New AbuTween(owner, name, value, duration, flags)
		_tweens.Set(name, tweenNew)
	End
	
	Method PauseTween:Void(name:String)
		_tweens.Get(name).Pause()
	End
	
	Method ResumeTween:Void(name:String)
		_tweens.Get(name).Resume()
	End
	
	Method RemoveTween:Void(name:String)
		_tweens.Get(name).Destroy()
		_tweens.Remove(name)
	End
	
	Method ClearTweens:Void()
		For Local tween := Eachin _tweens.Values()
			tween.Destroy()
		Next
		_tweens.Clear()
	End
	
	Method OnTweenComplete:Void(name:String)
	
	End
	
	Method AddTimer:Void(name:String, timeTargetRelative:Int = 0)
		Local timerNew := New AbuTimer(timeTargetRelative)
		_timers.Set(name, timerNew)
	End
	
	Method PauseTimer:Void(name:String)
		_timers.Get(name).Pause()
	End
	
	Method ResumeTimer:Void(name:String)
		_timers.Get(name).Resume()
	End
	
	Method RemoveTimer:Void(name:String)
		'_timers.Get(name).Destroy()
		_timers.Remove(name)
	End
	
	Method ClearTimers:Void()
		#Rem
		For Local timer := Eachin _timers.Values()
			timer.Destroy()
		Next
		#End
		_timers.Clear()
	End
	
	Method OnTimerComplete:Void(name:String)
	
	End
	
Private
	Field _tweens := New StringMap<AbuTween>
	Field _timers := New StringMap<AbuTimer>
End